using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.ProcessFlow;
using emp.BLL;
using emp.Model;

public partial class crm_cell_condition_ConditionPreviewExport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CellCondition conpre = new CellCondition();
        IList conprelist = conpre.getConditionPreviewList();
        GridView1.DataSource = conprelist;
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        CellCondition conpre = new CellCondition();
        IList conprelist = conpre.getConditionPreviewList();
        GridView1.DataSource = conprelist;
        GridView1.DataBind();
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        CellCondition conpre = new CellCondition();
        CellConditionPreviewInfo conpreinfo = new CellConditionPreviewInfo ();
        
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string rowid = "0";
            if (e.Row.Cells[0].Text != "")
            {
                rowid = e.Row.Cells[0].Text;
            }
            conpreinfo = conpre.getConditionPreviewInfo(int.Parse(rowid.ToString ()));
            Label labexportimg = (Label)(e.Row.FindControl("labexportimg"));
            if (conpreinfo.CCP_TEMPLATE == "1")
            {
                labexportimg.Text = "<table align=\"left\"><tr>";
                if (conpreinfo.CCP_FILE_1 != "")
                {
                    labexportimg.Text += "<td>" + "&nbsp;&nbsp;<img src='../../../pub/crm/images/xmlimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign List(XML)' onclick=\"javascript:window.open(\'ConditionPreviewView.aspx?filename=" + conpreinfo.CCP_FILE_1 + "&ccp_id=" + conpreinfo.CCP_ID + "','','width=770,height=150,scrollbars=no','top.focus()');\"></td>";
                }
                else
                {
                    labexportimg.Text += "<td>" + "&nbsp;&nbsp;<img src='../../../pub/crm/images/waitimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign List(XML)Working...!'></td>";
                }
                if (conpreinfo.CCP_FILE_2 != "")
                {
                    labexportimg.Text += "<td>" + "&nbsp;&nbsp;<img src='../../../pub/crm/images/xmlimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign View(XML)' onclick=\"javascript:window.open(\'ConditionPreviewView.aspx?filename=" + conpreinfo.CCP_FILE_2 + "&ccp_id=" + conpreinfo.CCP_ID + "','','width=770,height=150,scrollbars=no','top.focus()');\"></td>";
                }
                else
                {
                    labexportimg.Text += "<td>" + "&nbsp;&nbsp;<img src='../../../pub/crm/images/waitimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign View(XML)Working...!'></td>";
                
                }
                if (conpreinfo.CCP_FILE_3 != "")
                {
                    labexportimg.Text += "<td>" + "&nbsp;&nbsp;<img src='../../../pub/crm/images/excelimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign List(Excel)' onclick=\"javascript:window.open(\'ConditionPreviewView.aspx?filename=" + conpreinfo.CCP_FILE_3 + "','','width=770,height=150,scrollbars=no','top.focus()');\"></td>";
                }
                else
                {
                    labexportimg.Text += "<td>" + "&nbsp;&nbsp;<img src='../../../pub/crm/images/waitimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign List(Excel)Working...!'></td>";
                }
                if (conpreinfo.CCP_FILE_4 != "")
                {
                    labexportimg.Text += "<td>" + "&nbsp;&nbsp;<img src='../../../pub/crm/images/excelimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign View(Excel)' onclick=\"javascript:window.open(\'ConditionPreviewView.aspx?filename=" + conpreinfo.CCP_FILE_4 + "','','width=770,height=150,scrollbars=no','top.focus()');\"></td>";
                }
                else
                {
                    labexportimg.Text += "<td>" + "&nbsp;&nbsp;<img src='../../../pub/crm/images/waitimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign View(Excel)Working...!'></td>";
                }
                labexportimg.Text += "</tr></table>";
            }
            if (conpreinfo.CCP_TEMPLATE == "2")
            {
                if (conpreinfo.CCP_FILE_1 != "")
                {
                    labexportimg.Text = "<img src='../../../pub/crm/images/excelimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='DM Maintancement' onclick=\"javascript:window.open(\'ConditionPreviewView.aspx?filename=" + conpreinfo.CCP_FILE_1 + "','','width=770,height=150,scrollbars=no','top.focus()');\">";
                }
                else
                {
                    labexportimg.Text += "<img src='../../../pub/crm/images/waitimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='DM Maintancement,Working...!'>";
                }
            }
            if (conpreinfo.CCP_TEMPLATE == "3" )
            {
                if (conpreinfo.CCP_FILE_1 != "")
                {
                    labexportimg.Text = "<img src='../../../pub/crm/images/excelimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign Others' onclick=\"javascript:window.open(\'ConditionPreviewView.aspx?filename=" + conpreinfo.CCP_FILE_1 + "','','width=770,height=150,scrollbars=no','top.focus()');\">";
                }
                else
                {
                    labexportimg.Text += "<img src='../../../pub/crm/images/waitimg.gif' name='Image1' border='0' style='cursor:hand' id='Image1' alt='Campaign Others,Working...!'>";
                }
            }
        }
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        CellCondition conpre = new CellCondition();
        IList conprelist = conpre.getConditionPreviewSearch(con_name .Text .Trim () ,con_date .Text);
        GridView1.DataSource = conprelist;
        GridView1.DataBind();
    }
}
